// pages/history/history.js
import api from '../../api/api'
import { urlObj } from '../../api/url'
const WxParse = require('../wxParse/wxParse.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    detail:{}
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getDetail()
  },

 
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  getDetail() {
    let _this = this;
    const params = {
      page:1,
      limit:50,
      types:2
    }
    api.get(urlObj.getProductList,params).then(res => {
      if(res.statusCode == '200') {
        let { items } = res;
        items.forEach(item => {
          item.picture = urlObj.imgHost + item.picture
        })
        this.setData({
          detail:items[0]
        })
        WxParse.wxParse('historyArticle', 'html', items[0].describes, _this,5);
      }
    }).catch(err => {
      console.log(err)
    })
  }
})